package io.gitee.twoke.generator.engine.impl.interceptor;

import io.gitee.twoke.generator.engine.impl.context.Context;
import lombok.extern.slf4j.Slf4j;

@Slf4j
public class CommandInvoker extends AbstractCommandInterceptor {

  @Override
  @SuppressWarnings("unchecked")
  public <T> T execute(final CommandConfig config, final Command<T> command) {
    return command.execute(Context.getCommandContext());
  }

  @Override
  public CommandInterceptor getNext() {
    return null;
  }

  @Override
  public void setNext(CommandInterceptor next) {
    throw new UnsupportedOperationException("CommandInvoker must be the last interceptor in the chain");
  }

}